const tool_ws = {
  init_start(host) {
    let socket = new WebSocket(host); // 替换为你的 WebSocket 服务器地址

    let msg_listens = [];

    socket.onmessage = function (event) {
      msg_listens.forEach((listen) => {
        listen(event.data);
      });
    };

    return {
      ws: socket,
      on_msg: (listen) => msg_listens.push(listen),
      send_msg: socket.send,
    };
  },
};

export default tool_ws;
